/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

/**
 *
 * @author Yongke
 */
import java.util.Vector;

public class RoomList {

    public RoomList()
    {
        AllRoomList = new Vector<Room>();
    }

    private Vector<Room> AllRoomList;

    public void AddRoom(Room R)
    {
        AllRoomList.add(R);
    }

    public Vector<Room> getAllRoomList(){return AllRoomList;}

    public int getNOfRoom(String username)
    {
        int N = 0;
        for (int i = 0; i < AllRoomList.size(); i++)
        {
            if (AllRoomList.elementAt(i).getOwner().equals(username))
            {
                N++;
            }
        }
        return N;
    }

    public boolean containingRoom(String rname)
    {
        boolean b = false;
        for (int i = 0; ((i < AllRoomList.size()) && !b); i++)
        {
            if (AllRoomList.elementAt(i).getRoomName().equals(rname))
            {
                b = true;
            }
        }
        return b;
    }

    public boolean getRoom(Room R, String rname)
    {
        boolean b = false;
        for (int i = 0; ((i < AllRoomList.size()) && !b); i++)
        {
            if (AllRoomList.elementAt(i).getRoomName().equals(rname))
            {
                b = true;
                R = AllRoomList.elementAt(i);
            }
        }
        return b;
    }

    public void removeRoom(String rname)
    {
        int i = 0;
        for (;((i < AllRoomList.size()) && !AllRoomList.elementAt(i).getRoomName().equals(rname)); i++)
        {}
        if (AllRoomList.elementAt(i).getRoomName().equals(rname))
        {
            AllRoomList.remove(i);
        }
    }

}
